<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/11/23
 * Time: 18:54
 */

$file = $_GET['path'];
downfile($file);
function downfile($file)
{
    $filename = realpath(dirname(__FILE__) . '/' . $file); //文件名
    $date = date("Y-m-d");
    Header("Content-type:  application/octet-stream ");
    Header("Accept-Ranges:  bytes ");
    Header("Accept-Length: " . filesize($filename));
    header("Content-Disposition:  attachment;  filename= {$date}.txt");
    echo file_get_contents($filename);
    readfile($filename);
}

